import { getWxConfig } from "@/config/api"
const state = {
    wxConfig: null
}

  const mutations = {
    SET_WX_CONFIG: (state, wxConfig) => {
        state.wxConfig = wxConfig
    }
  }

  const actions = {
    info({commit, dispatch}) {
        return new Promise((resolve, reject) => {
            uni.getSystemInfo({
                success: function (res) {
                    console.log(res.model);
                    console.log(res.pixelRatio);
                    console.log(res.windowWidth);
                    console.log(res.windowHeight);
                    console.log(res.language);
                    console.log(res.version);
                    console.log(res.platform);
                    resolve(res)
                }
            })
        })
    },
    setWxConfig({commit}) {
        return new Promise((resolve, reject) => {
            getWxConfig({}).then(res => {
                commit("SET_WX_CONFIG", res)
                resolve(res)
            })
        })
    }
  }


  export default {
    namespaced: true,
    state,
    mutations,
    actions
  }
